<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <input v-model="text">
        <button @click="add">添加</button>
        <p>{{text}}</p>
        <hr>
        <p v-for="(item,index) in arr" :key="index">
            <span>{{item}}</span>
            <button @click="clear(index)">删除</button><br>
        </p>
        <span v-show="index!=0">总计：{{index}}条</span>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/vue@2"></script>
    <script>
        var app = new Vue({
            el: '#app',
            data: {
                text: '',
                arr: [],
                index: 0
            },
            methods: {}
        })
    </script>
</body>

</html>